<?
	session_start();
	include('conn.php');
	$rev1=$_REQUEST['rev1'];
	$rev2=$_REQUEST['rev2'];
	$rev3=$_REQUEST['rev3'];	
	$username = $_SESSION['username'];
	
	$sql2="SELECT MAX(trnid) FROM  transactionmast where enteredby = '$username'"; 		
	$res2=mysql_query($sql2);			
	while($rows = mysql_fetch_array($res2))
		$tid = $rows[0];	
	$rcnt=0;
	if($rev1 == "true")
		$rcnt++;
	if($rev2 == "true")
		$rcnt++;
	if($rev3 == "true")
		$rcnt++;
	$tid=$tid-$rcnt;
	
	if(strcmp ($_REQUEST["x"],'1')==0)
	{		
		$acharge=[];
		$sql1="select appadmchrg from customermast where custid=(select venid from transactionmast where trnid=".$tid.");";
		$res1=mysql_query($sql1);
		while($rowb=mysql_fetch_assoc($res1))
			$acharge[0]=$rowb['appadmchrg'];
		$sql1="select appadmchrg from customermast where custid=(select venid2 from transactionmast where trnid=".$tid.");";
		$res1=mysql_query($sql1);
		while($rowb=mysql_fetch_assoc($res1))
			$acharge[1]=$rowb['appadmchrg'];
		$sql1="select appadmchrg from customermast where custid=(select venid3 from transactionmast where trnid=".$tid.");";
		$res1=mysql_query($sql1);
		while($rowb=mysql_fetch_assoc($res1))
			$acharge[2]=$rowb['appadmchrg'];
		echo json_encode($acharge);
	}
	else{	
	$i = 0;	
	$data = [];
	$sql = "select * from transactiondetails where tranid=".$tid;	
	$res=mysql_query($sql);		
	//echo $sql."-------".$res;
	
	while($row = mysql_fetch_assoc($res))	
	{				
		/*if (strcmp ($bdt,'1970-01-01')==0)	
			$bdt='-';
		$tdt =$row['Travel Date'];
		if (strcmp ($tdt,'1970-01-01')==0)	
			$tdt='-';
		$rdt =$row['Return Date'];
		if (strcmp ($rdt,'1970-01-01')==0)	
			$rdt='-';*/
		$bdt=$row['Bkng Date'];
		$rdt =$row['Return Date'];
		$tdt =$row['Travel Date'];
		$Pax_Name =$row['Pax Name'];
		$tno =$row['Ticket Number'];
		$pnr =$row['PNR'];
		$sec =$row['Sector'];
		$basic =$row['Basic'];
		$tax =$row['Tax'];
		$admin =$row['Admincharges'];
		$amt =$row['Amount'];		
		
		$data[$i] = array(				  
		  "tranid" => $tid,
		  "paxname" => $Pax_Name,
		  "bdt" => $bdt,
		  "rdt" => $rdt,
		  "tdt" => $tdt,
		  "tno" => $tno,
		  "pnr" => $pnr,
		  "sec" => $sec,
		  "bc" => $basic,
		  "ac" => $admin,		  
		  "amt" => $amt,
		  "tax" => $tax);		
		$i++;
	}	
	echo json_encode($data);		
	}
?>
